package springboot.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import springboot.demo.config.UserConfig;
import springboot.demo.service.UserService;

@Controller
public class HelloController {
//    //属性注入
//    @Autowired
//    private UserService us;

    private UserService us;

    private UserConfig userConfig;
    //构造方法注入
//    public HelloController(UserService us) {
//        this.us = us;
//    }

//    public HelloController(UserService us, UserConfig userConfig) {
//        this.us = us;
//        this.userConfig = userConfig;
//    }

    //setter注入
    @Autowired
    public void setUs(UserService us) {
        this.us = us;
    }
    @Autowired
    public void setUserConfig(UserConfig userConfig) {
        this.userConfig = userConfig;
    }

    public void print(){
        System.out.println("do Controller");
        System.out.println(us);
        us.print();
        userConfig.print();
    }

}
